Running real JavaScript in parallel, without touching the DOM.
A Web Worker runs a JavaScript file on its own thread, completely separate from the main thread that handles your UI. That separation is the whole point: heavy computation (image processing, large data parsing, complex calculations) can run on a worker without ever blocking the main thread, which is what keeps the UI responsive during expensive work. The tradeoff is isolation — a worker has no access to the DOM, window, or the variables in your main script.
Workers and the main thread communicate exclusively by passing messages through postMessage(), and the data sent is copied via the structured clone algorithm by default — not shared by reference. For large binary data like an ArrayBuffer, you can use transferable objects instead, which move ownership to the worker without copying, at the cost of the original thread losing access to that data. Dedicated workers belong to one script; SharedWorkers can be accessed by multiple scripts or tabs from the same origin.
What you'll walk away knowing